<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>连锁干洗中心业务管理系统</title>
    <%- include('css') %>
    <style>


    </style>
</head>

<body class="layui-layout-body">

    <div class="layui-row" style="margin-top: 10%;">
        <div class="layui-col-md4 layui-col-md-offset4"  >
            <fieldset class="layui-elem-field" >
                <legend>管理平台 - 登录</legend>
                <div class="layui-field-box" style="margin-top: 3%">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" required lay-verify="required" placeholder="请输入用户名" autocomplete="off"
                                    class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密 码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码"
                                    autocomplete="off" class="layui-input">
                            </div>

                        </div>

                        <div class="layui-form-item">
                            <div style="text-align: center">
                                <button class="layui-btn" lay-submit lay-filter="formDemo">登录</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
        </div>
    </div>


    <%- include('script') %>
    <script>
        layui.use(['form','layer'], function () {
            var form = layui.form;
            var layer = layui.layer;
            console.info(layer);

            //监听提交
            form.on('submit(formDemo)', (data) => {
                $.post("/admin/access/login",{data:data.field},(res)=>{
                        if(res.code == 200){
                            layer.msg('登录成功！', {icon: 1});
                            setTimeout(()=>{
                                window.location.href = '/admin/access/index'
                            },1000);
                            //icon 1绿√ 2红叉 3问号 4密码锁 5不开心 6开心
                        }else{
                            layer.msg('登录失败:'+res.error+' -- '+res.code,{icon:2})
                        }
                    });
                return false;
            });
        });
    </script>
</body>

</html>
